CC := aarch64-linux-gnu-gcc
INC := $(wildcard inc/*.c)
INH := ./inh \
	   ./hso/usr/local/include \
	   ./hso/usr/include \
	   ./hso/usr/include/aarch64-linux-gnu \
	   ./hso/usr/include/aarch64-linux-gnu/python3.10 \
	   ./hso/usr/include/python3.10 \
	   ./hso/usr/include/python3.10/cpython \
	   ./hso/usr/include/python3.10/internal
	
TARGET = obj/toysort
#OBJ:= $(patsubst inc/%,obj/%,$(INC:.c=.o))

h_flag  := $(foreach var,$(INH),-I $(var))
so_flag := ./hso/lib/aarch64-linux-gnu \
	       ./hso/usr/lib/aarch64-linux-gnu \
		   ./hso/usr/lib/python3.10/config-3.10-aarch64-linux-gnu \
		   ./hso/usr/local/lib 
L_flag  := $(foreach var,$(so_flag),-L $(var))
l_flag  := -lwiringPi -lpython3.10 -lcrypt -lexpat -lz -lpthread

#obj/%.o: inc/%.c
#	mkdir -p obj
#	$(CC) -o $@ -c $< $(h_flag)

DEBUG:
	@echo $(CC)
	@echo $(INC)
	@echo $(INH)
	@echo $(h_flag)
	@echo $(so_flag)
	@echo $(L_flag)
	@echo $(l_flag)

$(TARGET): $(INC)    #$(OBJ) 
	mkdir -p obj
	$(CC) -o $@ $^ $(h_flag) $(L_flag) $(l_flag)

compile: $(TARGET)

clean:
	rm obj -rf 

.PHONY: compile clean